#!/bin/bash
# http://hk1.php.net/get/php-7.2.14.tar.gz/from/this/mirror
echo "现在安装php7"
 

# HERE=`cd $(dirname $0); pwd -P` #脚本目录
# HERE="${HERE}/"
# echo ${HERE}
# MYLAMP="/var/local/mylamp/" #安装目录
# TOOLS="${MYLAMP}tools/" #工具目录
# PACKAGE="$(pwd)/package/" #安装包目录
# APACHEDIR="${MYLAMP}apache/" #Apache安装目录
# PHPDIR="${MYLAMP}php/" #php安装目录



cd ${HERE}
if [ ! -f "${PACKAGE}mirror" ]
then
    wget -P "${PACKAGE}"  http://hk1.php.net/get/php-7.2.14.tar.gz/from/this/mirror  #1.下载安装包
fi


tar -zxvf "${PACKAGE}mirror" -C  ${PACKAGE} #2解压
cd "${PACKAGE}php-7.2.14"
./configure --prefix=${PHPDIR}  --with-apxs2=${APACHEDIR}httpd/bin/apxs  --with-curl --enable-fpm --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl  --with-zlib --enable-bcmath --enable-libxml --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets  --enable-sysvsem  --enable-xml --enable-zip
make clean
make 
make install

if [ ! -f "${MYLAMP}www/index.php" ]
then
    touch ${MYLAMP}www/index.php
    echo "<?php" > ${MYLAMP}www/index.php
    echo "phpinfo();" >> ${MYLAMP}www/index.php
else
    rm -fr ${MYLAMP}www/index.php
    touch ${MYLAMP}www/index.php
    echo "<?php" > ${MYLAMP}www/index.php
    echo "phpinfo();" >> ${MYLAMP}www/index.php
fi



 
#将源码中的php.ini-development复制到设置的 php.ini 的搜索路径下
cp php.ini-development ${PHPDIR}lib/php.ini
 
#复制一份php- fpm配置文件，命名为php-fpm.conf（/usr/local/php72/etc路径下）
cp ${PHPDIR}etc/php-fpm.conf.default ${PHPDIR}etc/php-fpm.conf
cp ${PHPDIR}etc/php-fpm.d/www.conf.default  ${PHPDIR}etc/php-fpm.d/www.conf

cd ${HERE}